package edu.whu.tao.service;

import java.io.Serializable;
import java.util.List;

import org.hibernate.criterion.DetachedCriteria;

import edu.whu.tao.util.CommonResult;
import edu.whu.tao.util.PageData;

public interface GenericService<T> {

	/**
	 * 
	 * <p>软删除的数据未清掉</p>
	 * @param id
	 * @return
	 * @author 陶焕(13294175866)
	 */
	CommonResult<T> get(Serializable id) throws Exception;
	
	/**
	 * 
	 * <p>将已经被软删除的数据清掉</p>
	 * @param id
	 * @return
	 * @author 陶焕(13294175866)
	 */
	CommonResult<T> getById(Serializable id) throws Exception;
	
	CommonResult<T> getOneByCri(DetachedCriteria detachedCriteria) throws Exception;
	
	CommonResult<T> update(T entity) throws Exception;

	CommonResult<T> save(T entity) throws Exception;
	
	CommonResult<Integer> deleteHard(T entity) throws Exception;
	
	CommonResult<Integer> deleteHardByKey(Serializable id) throws Exception;

	CommonResult<Integer> deleteHardByKeys(Serializable[] ids) throws Exception;

	CommonResult<Integer> deleteSoftByKey(Serializable id) throws Exception;

	CommonResult<Integer> deleteSoftByKeys(Serializable[] ids) throws Exception;
	
	CommonResult<Long> count(DetachedCriteria detachedCriteria) throws Exception;
	
	CommonResult<Integer> saveOrUpdateAll(List<T> entities) throws Exception;
	
	CommonResult<T> findByCriteria(DetachedCriteria detachedCriteria) throws Exception;

	CommonResult<T> findByCriteria(DetachedCriteria detachedCriteria, int page, int row) throws Exception;

	PageData<T> getByPage(DetachedCriteria detachedCriteria, int page, int row) throws Exception;
	
	CommonResult<T> sqlQuery(String querySql, Object... params) throws Exception;

	CommonResult<T> sqlQuery(String querySql, Object[] paramNames, int page, int row) throws Exception;
	
	CommonResult<Integer> updateBySql(String updateSql, Object... params) throws Exception;

	CommonResult<Integer> updateBySql(String updateSql, String[] paramNames, Object... params) throws Exception;
	
}
